﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VipCo.Entities;
using VipCo.Data;
using System.Data;
using System.Threading;

public partial class TimKiem : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            if (Request.QueryString["DiaDiem"] != null)
            {
                Pager1.CurrentIndex = 1;
                HienThiNhomDiaDiem(Pager1.CurrentIndex);
            }
        }
    }

    private void HienThiNhomDiaDiem(int PageNo)
    {
        int TotalRows = 0;
        string WhereClause;
        if (Request.QueryString["IdThanhPho"] == null)
            WhereClause = "TenDiaDiem like N'%" + Request.QueryString["DiaDiem"] + "%'";
        else
            WhereClause = "TenDiaDiem like N'%" + Request.QueryString["DiaDiem"] + "%' and IdThanhPho=" + Request.QueryString["IdThanhPho"] + " and IdQuanHuyen=" + Request.QueryString["IdQuanHuyen"];
        DataSet dsTinTuc = DataRepository.Provider.ExecuteDataSet("DiaDiem_GetPaged", WhereClause, "NgayCapNhat DESC", PageNo - 1, Pager1.PageSize);
        dlChuyenmuc.DataSource = dsTinTuc;
        dlChuyenmuc.DataBind();
        try
        {
            TotalRows = Convert.ToInt32(dsTinTuc.Tables[1].Rows[0][0]);
        }
        catch (Exception)
        {
        }
        Pager1.ItemCount = TotalRows;
        if (TotalRows <= Pager1.PageSize)
            Pager1.Visible = false;
        else
            Pager1.Visible = true;
    }

    protected void Pager1_Command(object sender, CommandEventArgs e)
    {
        Thread.Sleep(2000);
        int currnetPageIndex = Convert.ToInt32(e.CommandArgument);
        Pager1.CurrentIndex = currnetPageIndex;
        HienThiNhomDiaDiem(currnetPageIndex);
    }

    public string GetTieuDe(object Char)
    {
        string s = Char.ToString();
        return Common.ConvertToUnSign(s);
    }
}